﻿Imports System
Imports System.Drawing
Imports System.Runtime.CompilerServices

Namespace System.Workflow.ComponentModel.Design
    Friend NotInheritable Class ActionButton
        Implements IDisposable
        ' Events
        Friend Custom Event StateChanged As EventHandler

        ' Methods
        Friend Sub New(ByVal stateImages As Image())
            Me.StateImages = stateImages
        End Sub

        Private Sub System.IDisposable.Dispose() Implements IDisposable.Dispose
        End Sub


        ' Properties
        Friend Property Description As String
            Get
                Return Me.description
            End Get
            Set(ByVal value As String)
                Me.description = value
            End Set
        End Property

        Friend Property State As States
            Get
                Return Me.buttonState
            End Get
            Set(ByVal value As States)
                If (Me.buttonState <> value) Then
                    Me.buttonState = value
                    If (Not Me.StateChanged Is Nothing) Then
                        Me.StateChanged.Invoke(Me, EventArgs.Empty)
                    End If
                End If
            End Set
        End Property

        Friend Property StateImages As Image()
            Get
                Return Me.stateImages
            End Get
            Set(ByVal value As Image())
                If (value Is Nothing) Then
                    Throw New ArgumentNullException("value")
                End If
                If ((value.Length <> 1) AndAlso (value.Length <> 4)) Then
                    Throw New ArgumentException(SR.GetString("Error_InvalidStateImages"), "value")
                End If
                Me.stateImages = value
                Dim image As Image
                For Each image In Me.stateImages
                    Dim bitmap As Bitmap = [TryCast](image,Bitmap)
                    If (Not bitmap Is Nothing) Then
                        bitmap.MakeTransparent(AmbientTheme.TransparentColor)
                    End If
                Next
            End Set
        End Property


        ' Fields
        Private buttonState As States
        Private description As String = String.Empty
        Private stateImages As Image()

        ' Nested Types
        Friend Enum States
            ' Fields
            Disabled = 3
            Highlight = 1
            Normal = 0
            Pressed = 2
        End Enum
    End Class
End Namespace

